package com.xqyq.dao;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xqyq.model.Admin;

@Repository
public class AdminDao {
	@Autowired
	private SessionFactory sessionFactory;
	
	public Admin login(Admin admin){
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from Admin where login_name=? and password=?");
		query.setString(0, admin.getLogin_name());
		query.setString(1, admin.getPassword());
		return (Admin) query.uniqueResult();
	}

}
